﻿//05.Write a program that calculates N!*K! / (K-N)! for given N and K (1<N<K).

using System;

namespace CalcFactorial
{
    class CalcFactorial
    {
        static void Main()
        {
            Console.Write("Enter the number K: ");
            int k = int.Parse(Console.ReadLine());
            Console.Write("Enter the number N: ");
            int n = int.Parse(Console.ReadLine());

            int factorialK = k;
            int factorialN = n;
            int factorialSub = (k - n);

            if (n <= 1 | k < n)
            {
                Console.WriteLine("K should be > 1 and N should be > K.");
            }
            else
            {
                for (int i = k - 1; i > 0; i--)
                {
                    factorialK *= i;
                }

                for (int j = n - 1; j > 0; j--)
                {
                    factorialN *= j;
                }

                for (int m = factorialSub - 1; m > 0; m--)
                {
                    factorialSub *= m;
                }

                Console.WriteLine("N! is: {0}", factorialN);
                Console.WriteLine("K! is: {0}", factorialK);
                Console.WriteLine("(K-N)! is: {0}", factorialSub);
                Console.WriteLine("The result of N!*K! / (K-N)! is: {0}.", (factorialN * factorialK) / factorialSub);
            }
        }
    }
}